<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>X-admin v1.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="__PUBLIC__/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">

            <form class="layui-form" method="post" action="" >
                <input type="hidden" name="id" value="{$list['id']}" >

                <label for="username" class="layui-form-label">公告类别</label>
                <div class="layui-input-inline" style="width:190px;text-align: left">
                    <select id="articletype" name="articletype" lay-verify="required">
                        <option value='' >--请选择--</option>
                        <option value="1" <if condition="$list['articletype'] eq 1" >selected</if> >校内公告</option>
                        <option value="2" <if condition="$list['articletype'] eq 2" >selected</if> >全校公告</option>
                        <option value="3" <if condition="$list['articletype'] eq 3" >selected</if> >社会公告</option>
                    </select>    
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">公告标题</label>
                    <div class="layui-input-inline">
                        <input type="text" id="titles" name="titles" value="{$list['title']}" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">公告内容</label>
                    <div class="layui-input-block">
                      <textarea name="remark" id="remark" rows="10" class="layui-textarea" required="" lay-verify="required" autocomplete="off">{$list['article']}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">添加</button>
                </div>
            </form>

        </div>
        <script src="__PUBLIC__/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="__PUBLIC__/X-admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>

            layui.use(['form','layer'], function(){
              $ = layui.jquery;
              var form = layui.form();
              layer = layui.layer;

              //监听提交
              form.on('submit(add)', function(data){
                
                id = $("input[name='id']").val();
                articletype = $("#articletype").val();
                titles = $("#titles").val();
                remark = $("#remark").val();

                $.post('__MODULE__/Homenotice/update',{id:id,articletype:articletype,titles:titles,remark:remark},function(data){
                    if(data=="成功"){
                        
                    }else{
                        alert('数据添加失败');
                        return false;
                    }
                });
                layer.alert("修改成功",{icon:6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.reload();
                });
                return false;
              });
            }); 
        </script>
    </body>

</html>